package com.example.vertification.service;

import com.example.vertification.entity.Order;
import com.example.vertification.entity.UserShop;
import com.example.vertification.repository.OrderRepository;
import com.example.vertification.repository.UserShopRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderService {


    private final OrderRepository orderRepository;

    @Autowired
    public OrderService(OrderRepository orderRepository) {
        this.orderRepository = orderRepository;
    }

    public Order getOrderByOrderNum(String num) {
        return orderRepository.findByOrderNumber(num);
    }

    public Order getOrderByOrderID(long id) {
        return orderRepository.findById(id);
    }


    public Order save(Order e) {
        return orderRepository.save(e);
    }
    public List<Order> getAllBuysByUserID(long uid) {
        return orderRepository.findAllByProductBuyerUid(uid);
    }

    public List<Order> getAllSellsByUserID(long uid) {
        return orderRepository.findAllByProductSellerUid(uid);
    }

}